<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
参数：
pageHolderName：PageHolder在requestScope里面的名字，默认为"pageHolder"。
--%>
<%
    if(request.getParameter("tip")!=null){
    	request.setAttribute("tip",request.getParameter("tip"));
    	
    }
	String pageHolderName=request.getParameter("pageHolderName");
	if(pageHolderName==null){
		pageHolderName="pageHolder";
	}
	pageContext.setAttribute("pageHolderName",pageHolderName);
	pageContext.setAttribute("pageHolder",request.getAttribute(pageHolderName));
	PageHolder p=(PageHolder)request.getAttribute(pageHolderName);
		int pageS = (p.getPageIndex()/10)*10+1;
		int pageE = p.getPageIndex()/10*10+10;
		if(p.getPageIndex()%10==0){
			pageE=p.getPageIndex();
			pageS=p.getPageIndex()-10+1;
		}
		pageE = pageE >p.getPageCount()?p.getPageCount():pageE;
		request.setAttribute("pageS",pageS);
		request.setAttribute("pageE",pageE);
%>

<%@page import="com.commons.page.PageHolder"%><c:if test="${pageHolder.rowCount>0}">
    <div class="page">
      <c:choose>
        <c:when test="${pageHolder.firstPage}"> <a>上一页</a></c:when>
        <c:otherwise>
          <c:url var="firstPage" value="">
            <c:param name="${pageHolder.pageIndexKey}" value="1"/>
          </c:url>
          <c:url var="previousPage" value="">
            <c:param name="${pageHolder.pageIndexKey}" value="${pageHolder.pageIndex-1}"/>
          </c:url>
           <a href="${previousPage}${pageHolder.params}">上一页${end}</a></c:otherwise>
      
      </c:choose>
      <c:forEach  begin="${pageS}" end="${pageE}" var="i" >
      		<c:choose>
      			<c:when test="${pageHolder.pageIndex == i}"><a class="f" href="?${pageHolder.pageIndexKey}=${i}${pageHolder.params}" >${i}</a></c:when>
      			<c:otherwise><a  href="?${pageHolder.pageIndexKey}=${i}${pageHolder.params}">${i}</a></c:otherwise>
      		</c:choose>
      </c:forEach>
      <c:choose>
        <c:when test="${pageHolder.lastPage}"><a>下一页</a> </c:when>
        <c:otherwise>
          <c:url var="nextPage" value="">
            <c:param name="${pageHolder.pageIndexKey}" value="${pageHolder.pageIndex+1}"/>
          </c:url>
          <c:url var="lastPage" value="">
            <c:param name="${pageHolder.pageIndexKey}" value="${pageHolder.pageCount}"/>
          </c:url>
          <a href="${nextPage}${pageHolder.params}">下一页</a> </c:otherwise>
      </c:choose>
      	共${pageHolder.pageCount}页
     </div>
</c:if>